import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const actions = {
    jia(context, value) {
        console.log('@@actions - jia');
        context.commit('JIA', value)
    },
    jian(context, value) {
        console.log('@@actions - jian');
        context.commit('JIAN', value)
    },
}

const mutations = {
    JIA(state, value) {
        console.log('@@mutations - JIA');
        state.sum += value
    },
    JIAN(state, value) {
        console.log('@@mutations - JIAN');
        state.sum -= value
    },
}

const state = {
    sum: 0
}

const getters = {
    bigSum(state) {
        return state.sum * 10
    }
}

const store = new Vuex.Store({
    actions,
    mutations,
    state,
    getters
})

export default store